<template>
  <div class="header flex">
    <div class="header-left flex">
      <h3>叩丁狼电商运营平台</h3>
      <el-icon>
        <Grid @click="isShowMenu = !isShowMenu" />
      </el-icon>
    </div>
    <div>
      <el-dropdown>
        <span class="el-dropdown-link">
          {{ username }}
          <el-icon class="el-icon--right">
            <arrow-down />
          </el-icon>
        </span>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item>首页</el-dropdown-item>
            <el-dropdown-item @click="exit">退出</el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>
    </div>
  </div>
  <div class="con flex">
    <div class="con-l">
      <Menu :isCollapse="isShowMenu" />
    </div>
    <div class="con-r">
      <router-view></router-view>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ArrowDown, Grid } from '@element-plus/icons-vue';
import { computed, ref } from 'vue';
import Menu from '@/components/Menu/index.vue';
import Cookies from 'js-cookie';
import { useRouter } from 'vue-router';
import { ElMessage } from 'element-plus'
import { useUserStore } from '@/store/modules/user'
const useStore = useUserStore()
const isShowMenu = ref(false);
const router = useRouter()
function exit() {
  Cookies.remove('token')
  ElMessage.success('退出成功!')
  router.push('/login')
}
const username = computed(() => useStore.username)
</script>

<style lang="less" scoped>
.example-showcase .el-dropdown-link {
  cursor: pointer;
  color: var(--el-color-primary);
  display: flex;
  align-items: center;
}

.flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header {
  height: 70px;
  background-color: #409eff;
  color: #fff;
  padding: 0 20px 0;
  box-sizing: border-box;

  h3 {
    margin-right: 20px;
  }
}

:deep(.el-dropdown) {
  color: #fff;
}

.con {
  position: absolute;
  top: 70px;
  left: 0;
  height: calc(100% - 70px);
  width: 100%;
  align-items: start;

  .con-l {
    height: 100%;
    background-color: #304156;
    overflow-y: auto;
    -ms-overflow-style: none;
    overflow: -moz-scrollbars-none;
  }

  .con-l::-webkit-scrollbar {
    width: 0 !important
  }

  .con-r {
    flex: 1;
    height: 100%;
    overflow-y: auto;
  }
}
</style>
